import 'package:json_annotation/json_annotation.dart';

part 'port.g.dart';

@JsonSerializable()
class Port {
  final String accountType; // "GROUP_PURCHASE_COIN",
  final String accountTypeName; // "消费券",
  final bool enabled; // 窗口是否正在营业
  final int hitTotal; // 当前用户在该窗口拼购时命中商品的总次数
  final int id; // 4,
  final int joinToday; // 当日用户在本窗口还能拼购的次数
  final int joinTotal; // 当前用户在该窗口参与拼购的总次数
  final bool joining; // 当前用户是否正在该窗口拼购
  final String openFee; // 单个窗口开通费用额度，仅用于显示
  final bool opened; // 当前用户是否开通了到该窗口拼购到资格
  final String portName; // "窗口3",
  final int bonusPoint; // 点

  Port(
    this.accountType,
    this.accountTypeName,
    this.enabled,
    this.hitTotal,
    this.id,
    this.joinToday,
    this.joinTotal,
    this.joining,
    this.openFee,
    this.opened,
    this.portName,
    this.bonusPoint,
  );

  factory Port.fromJson(Map<String, dynamic> json) => _$PortFromJson(json);

  Map<String, dynamic> toJson() => _$PortToJson(this);

  bool canJoin() {
    return !joining && joinToday > 0;
  }
}
